// 基于 SnowLang Project (https://gitee.com/jcnc-org/snow) 的衍生作品
// 原始版权归属: Copyright © 2025 Ke Xu (Luke)
// 本实现版权归属: Copyright © 2025 Sany
// 遵循 Apache License 2.0 授权
package commands

import (
	"fmt"

	"gitee.com/xntk2381/cc/pkg/task"
)

type RunCommand struct{}

func (RunCommand) Name() string {
	return "run"
}

func (RunCommand) Description() string {
	return "Run the compiled VM bytecode file (.water)"
}

func (c RunCommand) Execute(args []string) (int, error) {
	// 检查参数数量
	if len(args) == 0 {
		c.PrintUsage()
		return 1, nil
	}

	task := task.NewRunTask(args)
	err := task.Run()
	if err != nil {
		return 1, err
	}

	return 0, nil
}

func (RunCommand) PrintUsage() {
	fmt.Println("Usage:")
	fmt.Println("  snow run <program.water>")
}
